-- enemy_ability_damage
-- create by wangy
-- 敌方战力的N%伤害

return {
    apply = function(source, target, skillId, round, para, value)
        -- 造成敌方战力N%的伤害(hp:当前战力，fight_ability：总战力)
        local damage = value[1];
        local cure = value[2];
        local debuff = value[3];
        target:receiveDamage(damage);
        trace("enemy_ability_damage", "%s 受到 %d 点伤害，当前生命值 %d",
            target:getName(), damage, target:queryAttrib("hp"));

        -- 尝试吸血
        if cure > 0 then
            source:addAttrib("hp", cure);
            trace("enemy_ability_damage", "%s 回复 %d 点生命，当前生命值 %d", source:getName(), cure, source:queryAttrib("hp"));
        end

        if #debuff > 0 then
            -- 记录属性
            PropM.recordDebuff(target, debuff);
        end

        return { ["damage"] = damage, ["cure"] = cure, };
    end,

    parse = function(desc)
        local arr = string.explode(desc, ",");
        return { tonumber(arr[1]), arr[2], tonumber(arr[3] or 0)};
    end,

    getDetail = function(para)
        local desc;
        local value = para[1] / 10;
        local valueLimit = para[3] / 10;

        -- 分为按总战力计算和按当前战力计算
        if para[2] == "fight_ability" then
            desc = getLocStr("shipskill_enemy_ability_damage_1");
        elseif para[2] == "hp" then
            desc = getLocStr("shipskill_enemy_ability_damage_2");
        end


        desc = string.format(desc, value, valueLimit);

        return desc;
    end,
};
